package com.ayun.member.controller;


import com.ayun.base.Result;
import com.ayun.member.entity.Staff;
import com.ayun.member.service.IStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 斌叔
 * @since 2022-05-09
 */
@RestController
@RequestMapping("/staff")
public class StaffController {

    @Autowired
    private IStaffService staffService;

    @RequestMapping("/add")
    public Result add(@RequestBody Staff staff) {
        return staffService.add(staff);
    }

    @PostMapping("/login")
    public Result login(@RequestBody Staff staff) {
        return staffService.login(staff.getUsername(), staff.getPassword());
    }

    @GetMapping("/info/{token}")
    public Result getUserInfo(@PathVariable("token") String token) {
        return staffService.getUserInfo(token);
    }

    //退出系统
    @PostMapping("/logout")
    public Result logout() {
        return Result.ok();
    }

}
